A cautionary tale in advection

Periodic problem with forward Euler

For $a > 0$

$$ \begin{cases} u_t + a u_{x} = 0,\\ u(x,0) = \eta(x),\\ u(0,t) = u(1,t). \end{cases} $$

Build MOL matrix

$$ U'(t) = A U(t).$$

Periodic problem with leapfrog

For $a > 0$

$$ \begin{cases} u_t + a u_{x} = 0,\\ u(x,0) = \eta(x),\\ u(0,t) = u(1,t). \end{cases} $$

which gives

$$ U^{n+1} = U^{n-1} + 2 k S U^n.$$

We compute $U^1$ with forward Euler and begin the iteration.

We are solving $U' = A U$ and all the eigenvalues of $A$ are purely imaginary:

Recall the stability region for leapfrog. So, as long as the eigenvalues of $A$ do not exceed 1 in absolute value, the method will be stable --- $|ak/h| \leq 1$.

At the stability boundary

The method is stable, but not accurate!

Just beyond the stability boundary:

Dirichlet BC with leapfrog

For $a > 0$

$$ \begin{cases} u_t + a u_{x} = 0,\\ u(x,0) = \eta(x),\\ u(0,t) = g_0(t). \end{cases} $$

which gives

$$ U^{n+1} = U^{n-1} + 2 k A U^n.$$

We compute $U^1$ with forward Euler and begin the iteration. But now the last row of $A$ has to be modified.

First try forward Euler

Then go to leapfrog: